package com.example.wsdemo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;

import android.os.Bundle;
import android.view.View;

import com.example.viewmodel.WSSocketViewModel;
import com.example.wsdemo.databinding.ActivityWSBinding;

public class WSActivity extends AppCompatActivity {

    WSSocketViewModel wsSocketViewModel;
    public final String wssUrl="wss://i.camvv.com/room?roomid=27201";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityWSBinding binding = ActivityWSBinding.inflate (getLayoutInflater());
        setContentView(binding.getRoot());
        wsSocketViewModel=new WSSocketViewModel(wssUrl,getApplicationContext(),binding.scrollView);
        binding.setVm(wsSocketViewModel);
    }

    @Override
    protected void onDestroy() {
        wsSocketViewModel.disconnect(1000, "App exited");
        super.onDestroy();
    }
}